package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.LemonlaDialogueMapper;
import org.linlinjava.litemall.db.dao.LemonlaSessionMapper;
import org.linlinjava.litemall.db.domain.LemonlaDialogue;
import org.linlinjava.litemall.db.domain.LemonlaDialogueExample;
import org.linlinjava.litemall.db.domain.LemonlaSession;
import org.linlinjava.litemall.db.domain.LemonlaSessionExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class LemonlaDialogueService {
    @Resource
    private LemonlaDialogueMapper mapper;


    public List<LemonlaDialogue> queryBySessionId(Integer sessionId) {
        LemonlaDialogueExample example = new LemonlaDialogueExample();
        example.or().andDeletedEqualTo(false).andSessionIdEqualTo(sessionId);
        example.setOrderByClause("serial_number  asc");
        return mapper.selectByExample(example);
    }

    public void add(LemonlaDialogue dialogue) {
        dialogue.setAddTime(LocalDateTime.now());
        dialogue.setUpdateTime(LocalDateTime.now());
        mapper.insertSelective(dialogue);
    }
}
